<template>
	<view>
		<empty v-if="list.length==0"></empty>
		<view class="flex_l flex-wrap pl-36">
			<goodItem style="width: 46%;" class="mr-20 mtb-10" :item="item" v-for="(item, key) in list" :key="key"></goodItem>
		</view>
		<u-loadmore v-show="list.length>9" :status="status" icon-type="flower" bg-color="transperant" margin-top="30"
		 margin-bottom="30" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				status: 'loadmore',
				list: [],
			};
		},
		onPullDownRefresh() {
			this.page = 1
			this.list = []
			this.getList()
		},
		onReachBottom() {
			//避免多次触发
			if (this.status == 'loading' || this.status == 'nomore') {
				return;
			}
			this.getList()
		},
		onLoad() {
			this.getList()
		},
		methods: {
			getList() {
				this.status = "loading";
				this.$http('/api/shop/special_offer', {
					is_type: 2,
					page: this.page
				}).then(data => {
					if (data.length < 10) {
						this.status = "nomore"
					} else {
						this.page = this.page + 1
						this.status = "loadmore"
					}
					this.list = this.list.concat(data)
					uni.stopPullDownRefresh();
				})
			},
		}
	}
</script>

<style lang="scss">

</style>
